package net.huashitong.ssydt.provider.h5.currentpolitics.api;

import io.swagger.annotations.ApiOperation;
import net.huashitong.ssydt.exam.entity.vo.BaseQuestion;
import net.huashitong.ssydt.provider.h5.currentpolitics.dto.WxSdkDTO;
import net.huashitong.ssydt.provider.h5.currentpolitics.service.CurrentPoliticsService;
import net.huashitong.ssydt.provider.web.model.Result;
import net.huashitong.ssydt.provider.web.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.12.27
 */
@RestController
@RequestMapping("/h5/current-politics")
public class H5Controller {

    private CurrentPoliticsService currentPoliticsService;

    @Autowired
    public H5Controller(CurrentPoliticsService currentPoliticsService) {
        this.currentPoliticsService = currentPoliticsService;
    }


    @ApiOperation(value = "h5刷题数据接口", notes = "h5刷题数据接口", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping("/questions")
    public Result<ArrayList<BaseQuestion>> getQuestions() {
        List<BaseQuestion> vo = currentPoliticsService.getQuestions();
        return ResultUtils.getSuccessResultList(vo);
    }


    @ApiOperation(value = "获取微信授权信息", notes = "获取微信授权信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping("/wx/sdk")
    public Result<WxSdkDTO> getWxSdk() throws IOException {
        WxSdkDTO dto = currentPoliticsService.getWxSdk();
        return ResultUtils.getSuccessResults(dto);
    }

}
